programming4us
           
 
 
Programming

iPhone Programming : Table-View-Based Applications - Adding Navigation Controls to the Application

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
5/27/2011 11:29:47 AM
Next, back out the changes you just made to the tableView:didSelectRowAtIndexPath: method by deleting the lines you added in the preceding section (be careful to not remove the call to deselectRowAtIndexPath).

Now, let’s wrap this app up properly. This means we have to add a UINavigationController to the application. If you’ve used many iPhone apps, you’ll be familiar with this interface; it’s one of the most commonly used iPhone design interface patterns. Clicking on a cell in the table view makes the current view slide to the left and a new view is displayed. You return to the original table view by clicking on the Back button.

The first thing you need to do is add an IBOutlet to a UINavigationController to the app delegate interface (CityGuideDelegate.h):

#import <UIKit/UIKit.h>

@class RootController;

@interface CityGuideDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootController *viewController;
NSMutableArray *cities;
UINavigationController *navController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet RootController *viewController;
@property (nonatomic, retain) IBOutlet UINavigationController *navController;
@property (nonatomic, retain) NSMutableArray *cities;

@end


You also need to make some modifications to the app delegate implementation (CityGuideDelegate.m). Add a new line of code near the top to @synthesize the new property:

@synthesize window;
@synthesize viewController;
@synthesize cities;
@synthesize navController;

Now you need to replace the section of the code that adds the RootController main view as a subview of the main window. Delete the following line from the bottom of the applicationDidFinishLaunching: method:

[window addSubview:viewController.view];

Next, replace it with the code shown in bold in the following code snippet. This new code adds the RootController to the NavController’s stack of view controllers, making its view the current view of the NavController. Then it sets the current NavController view as the subview of the main window. The end of the applicationDidFinishLaunching: method should look like this now:

    // Override point for customization after app launch
navController.viewControllers = [NSArray arrayWithObject:viewController];
[window addSubview:navController.view];
[window makeKeyAndVisible];
}


As the current view of the NavController changes, it will automatically update the subview of the main window, and thus what the user sees on his screen. Let’s get this working first, and afterward I’ll discuss exactly how the NavController manipulates its stack of views.

Open the MainWindow.xib file in Interface Builder and drag and drop a navigation controller (UINavigationController) into the main NIB window (titled “MainWindow” or “MainWindow.xib”). The navigation controller is found on the Library (⌘-Shift-L) under Cocoa TouchControllers.

After doing so, you should see something similar to Figure 1. Note the navigation bar that appears at the top (with the title “City Guide”).

After adding the UINavigationController to the NIB, click on the CityGuide App Delegate icon in the main NIB window and switch to the Connections pane (⌘-2) of the Inspector window. Connect the navController outlet to the UINavigationController, as shown in Figure 5-15.

After performing this step, save the NIB file and return to Xcode. Open the RootController.m file and add the following snippet at the top of the viewDidLoad: method:

self.title =  @"City Guide";

We’ve reached another good time to take a break, so click Build and Run. If you’ve followed all the steps, you should see what I see, something that looks a lot like Figure 3.

Figure 1. Adding a UINavigationController to the MainWindow.xib NIB file


Figure 2. Connecting the UINavigationController to the outlet created in the application delegate code earlier


Figure 3. The CityGuide application is starting to look more like an iPhone application after adding a navigation bar

Other -----------------
- iPad SDK : Popovers - Popover Preparations
- iPad SDK : Preparing Dudel for a New Tool (part 5) - Rendering Multiple Styles
- iPad SDK : Preparing Dudel for a New Tool (part 4) - Creating a New Drawable Class
- jQuery 1.3 : AJAX - Loading data on demand (part 3) - Loading an XML document
- jQuery 1.3 : AJAX - Loading data on demand (part 2) - Working with JavaScript objects
- jQuery 1.3 : AJAX - Loading data on demand (part 1) - Appending HTML
- Coding JavaScript for Mobile Browsers (part 13) - Zoom and rotate gestures
- Coding JavaScript for Mobile Browsers (part 12) - Swipe gesture
- Coding JavaScript for Mobile Browsers (part 11)
- Coding JavaScript for Mobile Browsers (part 10) - Event Handling
- iPad SDK : Preparing Dudel for a New Tool (part 3) - Creating the Text Tool
- iPad SDK : Preparing Dudel for a New Tool (part 2) - Implementing Changes to the Controller Class
- Coding JavaScript for Mobile Browsers (part 9) - Scripting Styles
- Coding JavaScript for Mobile Browsers (part 8) - DOM
- iPad SDK : Preparing Dudel for a New Tool (part 1) - Setting Up the GUI
- Coding JavaScript for Mobile Browsers (part 7)
- Coding JavaScript for Mobile Browsers (part 6)
- iPad SDK : The Structure of Core Text
- iPad SDK : PDF Generation
- jQuery 1.3 : Sorting and paging (part 5) - Finessing the sort keys
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us